![]() |
FindWordBreaks |
||||
Header: | TextUtils.h | Carbon status: | Supported | |
Determines the beginning and ending boundaries of a word in a text string.
void FindWordBreaks ( Ptr textPtr, SInt16 textLength, SInt16 offset, Boolean leadingEdge, BreakTablePtr breaks, OffsetTable offsets, ScriptCode script );
A pointer to the text string to be examined.
The number of bytes in the text string.
A byte offset into the text. This parameter plus the leadingEdge parameter determine the position of the character at which to start the search.
A flag that specifies which character should be used to start the search. If leadingEdge is TRUE, the search starts with the character specified in the offset parameter; if it is FALSE, the search starts with the character preceding the offset.
A pointer to a word-break table of type NBreakTable or BreakTable. If the value of this pointer is 0, the default word-break table of the script system specified by the script parameter is used. If the value of this pointer is –1, the default line-break table of the specified script system is used.
On output, the values in this table indicate the boundaries of the word that has been found.
The script code for the script system whose tables are used to determine where word boundaries occur.
FindWordBreaks searches for a word in a text string, taking into account script and language considerations, making use of tables in the string-manipulation ('itl2') resource in its computations. The textPtr and textLength parameters specify the text string that you want searched. The offset parameter and leadingEdge parameter together indicate where the search begins.
FindWordBreaks searches backward through the text string for one of the word boundaries and forward through the text string for its other boundary. It uses the definitions in the table specified by nbreaks to determine what constitutes the boundaries of a word. Each script system’s word-break table is part of its string-manipulation ('itl2') resource.
FindWordBreaks returns its results in an OffsetTable structure, the format of which is described in the section OffsetTable. FindWordBreaks uses only the first element of this three-element table. Each element is a pair of integers: offFirst and offSecond.
FindWordBreaks places the offset from the beginning of the text string to just before the leading edge of the character of the word that it finds in the offFirst field.
FindWordBreaks places the offset from the beginning of the text string to just after the trailing edge of the last character of the word that it finds in the offSecond field. For example, if the text “This is it” is passed with offset set to 0 and leadingEdge set to TRUE, then FindWordBreaks returns the offset pair (0,4).
If leadingEdge is TRUE and the value of offset is 0, then FindWordBreaks returns the offset pair (0,0). If leadingEdge is FALSE and the value of offset equals the value of textLength, then FindWordBreaks returns the offset pair with values (textLength, textLength).
Supported in Carbon. Available in CarbonLib 1.0 and later when InterfaceLib 7.1 or later is installed. Exported by CarbonLib 1.0 and later and by InterfaceLib 7.1 and later.
© 2000 Apple Computer, Inc. — (Last Updated 4/14/2000)